home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / inames.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  4.2 KB  |  115 lines

  1. /* Copyright (C) 1998, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: inames.h,v 1.2 2000/09/19 19:00:45 lpd Exp $ */
  20. /* Name table interface */
  21.  
  22. #ifndef inames_INCLUDED
  23. #  define inames_INCLUDED
  24.  
  25. /*
  26.  * This file defines those parts of the name table API that depend neither
  27.  * on the implementation nor on the existence of a single distinguished
  28.  * instance.  Procedures in this file begin with names_.
  29.  */
  30.  
  31. /* ---------------- Interface types ---------------- */
  32.  
  33. #ifndef name_table_DEFINED
  34. #  define name_table_DEFINED
  35. typedef struct name_table_s name_table;
  36. #endif
  37.  
  38. typedef uint name_index_t;
  39.  
  40. /* ---------------- Constant values ---------------- */
  41.  
  42. extern const uint name_max_string;
  43.  
  44. /* ---------------- Procedural interface ---------------- */
  45.  
  46. #ifndef gs_ref_memory_DEFINED
  47. #  define gs_ref_memory_DEFINED
  48. typedef struct gs_ref_memory_s gs_ref_memory_t;
  49. #endif
  50.  
  51. /* Allocate and initialize a name table. */
  52. name_table *names_init(P2(ulong size, gs_ref_memory_t *imem));
  53.  
  54. /* Get the allocator for a name table. */
  55. gs_memory_t *names_memory(P1(const name_table * nt));
  56.  
  57. /*
  58.  * Look up and/or enter a name in the name table.
  59.  * The values of enterflag are:
  60.  *      -1 -- don't enter (return an error) if missing;
  61.  *       0 -- enter if missing, don't copy the string, which was allocated
  62.  *              statically;
  63.  *       1 -- enter if missing, copy the string;
  64.  *       2 -- enter if missing, don't copy the string, which was already
  65.  *              allocated dynamically (using the names_memory allocator).
  66.  * Possible errors: VMerror, limitcheck (if string is too long or if
  67.  * we have assigned all possible name indices).
  68.  */
  69. int names_ref(P5(name_table * nt, const byte * ptr, uint size, ref * pnref,
  70.          int enterflag));
  71. void names_string_ref(P3(const name_table * nt, const ref * pnref, ref * psref));
  72.  
  73. /*
  74.  * names_enter_string calls names_ref with a (permanent) C string.
  75.  */
  76. int names_enter_string(P3(name_table * nt, const char *str, ref * pnref));
  77.  
  78. /*
  79.  * names_from_string essentially implements cvn.
  80.  * It always enters the name, and copies the executable attribute.
  81.  */
  82. int names_from_string(P3(name_table * nt, const ref * psref, ref * pnref));
  83.  
  84. /* Compare two names for equality. */
  85. #define names_eq(pnref1, pnref2)\
  86.   ((pnref1)->value.pname == (pnref2)->value.pname)
  87.  
  88. /* Invalidate the value cache for a name. */
  89. void names_invalidate_value_cache(P2(name_table * nt, const ref * pnref));
  90.  
  91. /* Convert between names and indices. */
  92. name_index_t names_index(P2(const name_table * nt, const ref * pnref));        /* ref => index */
  93. name *names_index_ptr(P2(const name_table * nt, name_index_t nidx));    /* index => name */
  94. void names_index_ref(P3(const name_table * nt, name_index_t nidx, ref * pnref));    /* index => ref */
  95.  
  96. /* Get the index of the next valid name. */
  97. /* The argument is 0 or a valid index. */
  98. /* Return 0 if there are no more. */
  99. name_index_t names_next_valid_index(P2(name_table * nt, name_index_t nidx));
  100.  
  101. /* Mark a name for the garbage collector. */
  102. /* Return true if this is a new mark. */
  103. bool names_mark_index(P2(name_table * nt, name_index_t nidx));
  104.  
  105. /* Get the object (sub-table) containing a name. */
  106. /* The garbage collector needs this so it can relocate pointers to names. */
  107. void /*obj_header_t */ *
  108.     names_ref_sub_table(P2(name_table * nt, const ref * pnref));
  109. void /*obj_header_t */ *
  110.     names_index_sub_table(P2(name_table * nt, name_index_t nidx));
  111. void /*obj_header_t */ *
  112.     names_index_string_sub_table(P2(name_table * nt, name_index_t nidx));
  113.  
  114. #endif /* inames_INCLUDED */
  115.